#ifndef CPLO_PRINCIPAL
#define CPLO_PRINCIPAL
#include "cplo.cpp"
#include <cmath>
#include <list>
#ifdef MAP_HEIGHT
#ifdef MAP_WIDTH
#define INFINITO 1E+20

list<int>::iterator it_x, it_y;

void cplo::calcula() {
    for (int i = 0; i < MAP_WIDTH; i++)
        for (int j = 0; j < MAP_HEIGHT; j++) {
            mapa[i][j].setCteAtrativa(getCteAtrativa);
            mapa[i][j].setCteRepulsiva(getCteRepulsiva);
            mapa[i][j].setCteRepulsivaFixa(getCteRepulsivaFixa);
            for (it_x = at_x.begin(), it_y = at_y.begin(); it_x != at_x.end(); it_x++, it_y++)
                mapa[i][j].addAtrativa(*it_x, *it_y);
            for (it_x = rep_x.begin(), it_y = rep_y.begin(); it_x != rep_x.end(); it_x++, it_y++)
                mapa[i][j].addRepulsiva(*it_x, *it_y);
            for (it_x = repFixa_x.begin(), it_y = repFixa.begin(); it_x != repFixa_x.end(); it_x++, it_y++)
                mapa[i][j].addRepulsivaFixa(*it_x, *it_y);
        }




    for (int i = 0; i < MAP_WIDTH; i++)
        for (int j = 0; j < MAP_HEIGHT; j++) {
            getNeighborhood(i, j);
            int k = 0, kLessDist = -1;
            double lessDist = INFINITO;
            while (k <= getRobotListSize()) {
                dist = sqrt(pow(static_cast<double>(objeto[k][0])-i, 2)+pow(static_cast<double>(objeto[k][1]-j),2));
                if (dist < lessDist) {
                    lessDist = dist;
                    kLessDist = k;
                }
                k++;
            }
            if (lessDist < getRadiusOfInfluence()) {
                int obj_x = objeto[kLessDist][0];
                int obj_y = objeto[kLessDist][1];
                int x = getPotencialX(obj_x, obj_y);
                int y = getPotencialY(obj_x, obj_y);
                int lambda = epsilon;
                potencialX[i][j]= ((1+lambda*x)*vizinhos.right[0] + ((1-lambda*x)*vizinhos.left[0];
                PotencialX += ((1+lambda*y)*vizinhos.top[0] + ((1-lambda*y)*vizinhos.botton[0];
                PotencialY[i][j] = ((1+lambda*x)*vizinhos.right[1] + ((1-lambda*x)*vizinhos.left[1];
                potencialY[i][j] += ((1+lambda*y)*vizinhos.top[1] + ((1-lambda*y)*vizinhos.botton[1];

                }



#endif
#endif
#endif
